package easypal.brilliard.world.brilliards.logic;

public class HitState {
	public static final HitState begin = new HitState(BallColor.unknown);
	public static final HitState end = new HitState(BallColor.unknown);
	public static final HitState fault = new HitState(BallColor.unknown);
	public static final HitState red = new HitState(BallColor.red);
	public static final HitState multicolor = new HitState(BallColor.multicolor);
	public static final HitState green = new HitState(BallColor.green);
	public static final HitState yellow = new HitState(BallColor.yellow);
	public static final HitState brown = new HitState(BallColor.brown);
	public static final HitState blue = new HitState(BallColor.blue);
	public static final HitState pink = new HitState(BallColor.pink);
	public static final HitState black = new HitState(BallColor.black);
	
	//public static final HitState unknown = new HitState(BallColor.unknown);
	
	protected BallColor ballColor;
	
	private HitState(BallColor ball) {
		this.ballColor = ball;
	};
	
	/* Determine whether this ball color is allowed, which means 
	 * the ball of the color can be firstly touched and enter */
	public boolean isThisBallAllowed(BallColor color) {
		if (this == HitState.red && color == BallColor.red) {
			return true;
		}
		if (this == HitState.multicolor && color != BallColor.red
				&& color != BallColor.white && color != BallColor.unknown) {
			return true;
		}
		if (this == HitState.green && color == BallColor.green) {
			return true;
		}
		if (this == HitState.yellow && color == BallColor.yellow) {
			return true;
		}
		if (this == HitState.brown&& color == BallColor.brown) {
			return true;
		}
		if (this == HitState.blue && color == BallColor.blue) {
			return true;
		}
		if (this == HitState.pink && color == BallColor.pink) {
			return true;
		}
		if (this == HitState.black && color == BallColor.black) {
			return true;
		}
		
		return false;
	}
	
	public BallColor getBallColor() {
		return this.ballColor;
	}
	public String toString() {
		if (this == HitState.red ) {
			return "Red";
		}
		if (this == HitState.multicolor) {
			return "Multicolor";
		}
		if (this == HitState.green) {
			return "Green";
		}
		if (this == HitState.yellow) {
			return "Yellow";
		}
		if (this == HitState.brown) {
			return "Brown";
		}
		if (this == HitState.blue) {
			return "Blue";
		}
		if (this == HitState.pink) {
			return "Pink";
		}
		if (this == HitState.black ) {
			return "Black";
		}
		if (this == HitState.begin)
			return "Begin";
		if (this == HitState.end)
			return "End";
		
		return "Error";
	}
	
}

